package com.wyc.serviceDriverUser.controller;

import com.wyc.internalCommon.response.DriverOrderResponse;
import com.wyc.internalCommon.result.ApiResult;
import com.wyc.serviceDriverUser.dto.DriverCarBindingRelationship;
import com.wyc.serviceDriverUser.service.DriverCarBindingRelationshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 司机车辆绑定关联Controller
 */
@RestController
public class DriverCarBindingRelationshipController {

    @Autowired
    private DriverCarBindingRelationshipService driverCarBindingRelationshipService;

    /**
     * 司机绑定车辆
     * @param driverCarBindingRelationship
     * @return
     */
    @PostMapping("/driver-car-bind")
    public ApiResult bind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingRelationshipService.DriverBindCar(driverCarBindingRelationship);
    }

    /**
     * 司机解绑车辆
     * @param driverCarBindingRelationship
     * @return
     */
    @PostMapping("/driver-car-unbind")
    public ApiResult unBind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
        return driverCarBindingRelationshipService.DriverUnbindCar(driverCarBindingRelationship);
    }

    /**
     * 根据车辆id查询可接单的司机信息
     * @param carId
     * @return
     */
    @GetMapping("/get-available-driver/{carId}")
    public ApiResult<DriverOrderResponse> getAvailableDriverByCarId(@PathVariable("carId") Long carId){
        return driverCarBindingRelationshipService.getAvailableDriverByCarId(carId);
    }

}
